/* pfs05EntityEquipment.cpp
 *
 * --
 * Copyright (c) 2012, Christophe Huriaux
 * Distributed under the terms of the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * --
 */

#include <packet/pfs05EntityEquipment.h>
#include <wrapper/JavaStreamWrapper.h>

pfs05EntityEquipment::pfs05EntityEquipment()
    : McPacketFromServer(0x05), entityId(0), slot(0), item(0), damage(0)
{
}

unsigned int pfs05EntityEquipment::length()
{
    return 1 + 4 + 2 + 2 + 2;
}

int16_t pfs05EntityEquipment::setField(uint8_t field, void* value)
{

    switch (field)
    {
        case 0:
        default: return 4;
        case 1: entityId = JavaStreamWrapper::readInt(value); return 2;
        case 2: slot = JavaStreamWrapper::readShort(value); return 2;
        case 3: item = JavaStreamWrapper::readShort(value); return 2;
        case 4: damage = JavaStreamWrapper::readShort(value); return -1;
    }
}

int32_t pfs05EntityEquipment::getEntityId()
{
    return entityId;
}

int16_t pfs05EntityEquipment::getSlot()
{
    return slot;
}

int16_t pfs05EntityEquipment::getItem()
{
    return item;
}

int16_t pfs05EntityEquipment::getDamage()
{
    return damage;
}


